<?php
require_once "../Common/database.php";
require_once "../Common/values.php";
$_POST[due]=$_POST[dueday].'/'.$_POST[duemonth].'/'.$_POST[dueyear];

$result1="SELECT * FROM tblJobs WHERE LogNumber LIKE '%$datelog%' ORDER BY LogNumber DESC";
$result = mysql_query($result1);
$logid = 1;
$dateloglimit = $datelog+1 ;
$dateloglimit=$dateloglimit.'0';
$row = mysql_fetch_array($result);


if ($date==$row['Date'])
{


$Log=$row['LogNumber']+1;
if ($Log==$dateloglimit)
{
$Log=$datelog.'10';
}


 
}
else
{
$Log=$datelog.$logid ;

}

$_POST[problem]='User ID :'.$_POST[UserID].'
Applaction : '.$_POST[fran].'
Dealer Code : '.$_POST[code];
$result=mysql_query("SELECT * FROM tblstatus WHERE Name='$_POST[status]'");
$row = mysql_fetch_array($result);

$query="INSERT INTO tblJobs  (LogNumber,Operator,Requestor,Subject,Time,Date,Proirty,Line,Status,Problem,Branch,Department,Phone,VNC,Due,Assigned,Closed,Private,Project,Screenshot,mail) VALUES ('$Log','Public','$_POST[requestor]','Password reset request','$time','$date','Medium','$row[Line]','Pending','$_POST[problem]','$_POST[branch]','$_POST[department]','$_POST[phone]','$_POST[vnc]','$_POST[due]','Not Assigned','','','helpdesk','','$_POST[mailupdates]')";
mysql_query($query);
mysql_query("INSERT INTO tblevents (LogNumber,Date,Time,Operator,description,TimeS,`key`) VALUES ('$Log','$date','$time','Public','Created new job','0','')");

$_POST[subject]='Password reset request';

$_POST[mail]='new';
require "../Common/mail.php";

mysql_close();
echo '<center><h2>Job Logged ';
echo '<p>Log number '; echo $Log;

echo '<p><a href="../system/public.php">Back</a>';

?>